<template>
  <div class="container">
    <Header></Header>
    <div class="banner">
      <img src="@/static/images/index/banner.jpg" alt="" />
    </div>
    <div class="category">
      <ul>
        <li><img src="@/static/images/index/i1.jpg" alt="" /></li>
        <li><img src="@/static/images/index/i2.jpg" alt="" /></li>
        <li><img src="@/static/images/index/i2.jpg" alt="" /></li>
      </ul>
      <div>
        <img src="@/static/images/index/ih.jpg" alt="" />
      </div>
    </div>
    <div class="main">
      <ul>
        <li v-for="item in dataSource" :key="item.id" @click="toDetail">
          <img :src="require('@/static/images/index/' + item.img)" alt="" />
          <p class="title">{{ item.title }}</p>
          <p class="price">￥{{ item.price }}</p>
        </li>
      </ul>
    </div>
  </div>
  <Footer></Footer>
  <Tabbar></Tabbar>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import Header from '@/components/header/index.vue';
import Footer from '@/components/footer/index.vue';
import Tabbar from '@/components/tabbar/index.vue';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const mainData = require('@/mock/index/index.json');
import { useRouter } from 'vue-router';

export default defineComponent({
  components: {
    Header,
    Footer,
    Tabbar,
  },
  setup() {
    const isLogin = ref(false);
    const dataSource = mainData.data;
    const router = useRouter();

    return {
      isLogin,
      dataSource,
      router,
    };
  },
  methods: {
    toDetail() {
      this.router.push('/goods-detail');
    },
  },
});
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
}
.banner {
  width: 100%;

  img {
    width: 100%;
  }
}
.category {
  width: 844px;
  margin: 0 auto;

  ul {
    display: flex;
    transform: translateY(-50px);
    position: relative;

    li {
      border: 10px solid white;
    }
    &::before {
      content: '';
      position: absolute;
      width: 100%;
      height: 1px;
      top: 100%;
      background-color: #000;
    }
    &::after {
      content: '';
      position: absolute;
      width: 100%;
      height: 3px;
      top: 101%;
      background-color: #000;
    }
  }
  div {
    width: 100%;

    img {
      width: 100%;
    }
  }
}
.main {
  width: 1136px;
  margin: 0 auto;

  ul {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;

    li {
      width: 268px;

      img {
        width: 268px;
      }
      p {
        font-size: 16px;
        text-align: center;
      }
      .price {
        color: red;
      }
    }
  }
}
</style>
